﻿using NaughtyAttributes;
using UnityEditor;
using UnityEngine;

namespace Gj
{
#if UNITY_EDITOR
    public class PrefabExtend : MonoBehaviour
    {
        public string path;

        [Button]
        public void Apply()
        {
            PrefabUtility.SaveAsPrefabAsset(gameObject, path);
        }

        [Button]
        public void Revert()
        {
            PrefabUtility.RevertObjectOverride(gameObject, InteractionMode.UserAction);
        }

        [Button]
        public void IsConnect()
        {
            Debug.LogError(PrefabUtility.IsAnyPrefabInstanceRoot(gameObject));
        }

        [Button]
        public void Connect()
        {
            PrefabUtility.GetCorrespondingObjectFromSource(this);
        }
    }
#endif
}